home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
System.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-07
|
5KB
|
174 lines
#ifndef System_First
#ifdef __GNUG__
//pragma once
#pragma interface
#endif
#define System_First
#include "Object.h"
//---- class SysEvtHandler ---------------------------------------
// abstract class for handling events from system resources
enum SysEventCodes {
eSysEvtRead,
eSysEvtWrite,
eSysEvtZombie,
eSysEvtSignal,
eSysEvtAsyncSignal,
eSysEvtTimeout,
eSysEvtWork
};
class SysEvtHandler : public Object {
class SeqCollection *owner;
int resourceId;
protected:
~SysEvtHandler();
public:
MetaDef(SysEvtHandler);
SysEvtHandler(int resource);
int GetResourceId()
{ return resourceId; }
void SetResourceId(int id)
{ resourceId= id; }
virtual void Notify(SysEventCodes code, int val);
virtual bool HasInterest(SysEventCodes code);
void Remove();
bool IsEqual(Object *op);
void AddOwner(SeqCollection *o);
virtual int Error(int code);
};
//---- Signals -----------------------------------------------------------------
enum Signals {
eSigBus,
eSigSegmentationViolation,
eSigSystem,
eSigPipe,
eSigIllegalInstruction,
eSigQuit,
eSigInterrupt,
eSigWindowChanged,
eSigAlarm,
eSigChild,
eSigUrgent
};
//---- System ------------------------------------------------------------------
typedef void (*CallFunc)(void*, void*, void*, void*);
class System : public Object {
protected:
bool done;
char *errorstr, *osid;
bool environIsCopied;
SeqCollection *fileInputHandler;
SeqCollection *fileOutputHandler;
SeqCollection *zombieHandler;
SeqCollection *signalHandler;
SeqCollection *asyncSignalHandler;
SeqCollection *timeoutHandler;
SeqCollection *workHandler;
SeqCollection *cleanupList;
public:
static bool anyremoved;
public:
MetaDef(System);
System(char *name= "GENERIC");
virtual ~System();
virtual bool Init();
char *GetErrorStr()
{ return errorstr; }
virtual char *GetError();
char *GetSystemId()
{ return osid; }
virtual void Control();
void ExitControl();
virtual void InnerLoop(int timeout= 200);
virtual bool CanRead(int fd, int timeout);
virtual bool CanWrite(int fd, int timeout);
virtual class Directory *MakeDirectory(char *name);
virtual void Rename(char *from, char *to);
//---- expand the metacharacters in Pat as in the shell
virtual bool ExpandPathName(char *patbuf, int buflen);
virtual bool AccessPathName(char *path, int mode= 0);
virtual int GetPathInfo(char *path, int *id, long *size, int *flags, long *modtime);
virtual bool ChangeDirectory(char *path);
virtual char *WorkingDirectory();
virtual char *HomeDirectory();
virtual char *DirName(char *pathname);
virtual void Exit(int code, bool mode= TRUE);
virtual void Wait(unsigned int);
virtual void Abort(int code= 0);
virtual int GetPid();
//---- pseudo tty connection --------------------------------
virtual class PttyConnection *MakePttyConnection(char *prog, char **args);
//---- environment manipulation -----------------------------
virtual void Setenv(char *name, char *value);
// set environment variable name to value
virtual void Unsetenv(char *name);
// remove environment variable
virtual char *Getenv(char *);
//---- Dynamic Loading --------------------------------------
virtual Object *Load(char *progname, char *name);
//---- handling of system events ----------------------------
virtual void AddHandler(SeqCollection *s, SysEvtHandler *h);
virtual SysEvtHandler *RemoveHandler(SeqCollection *s, SysEvtHandler *h);
void AddFileInputHandler(SysEvtHandler *h)
{ AddHandler(fileInputHandler, h); }
void AddFileOutputHandler(SysEvtHandler *h)
{ AddHandler(fileOutputHandler, h); }
void AddZombieHandler(SysEvtHandler *h)
{ AddHandler(zombieHandler, h); }
void AddSignalHandler(SysEvtHandler *h) // synch
{ AddHandler(signalHandler, h); }
void AddAsyncSignalHandler(SysEvtHandler *h)
{ AddHandler(asyncSignalHandler, h); }
void AddTimeoutHandler(SysEvtHandler *h)
{ AddHandler(timeoutHandler, h); }
void AddWorkHandler(SysEvtHandler *h)
{ AddHandler(workHandler, h); }
void *RemoveTimeoutHandler(SysEvtHandler *h)
{ return RemoveHandler(timeoutHandler, h); }
void AddCleanupObject(Object*);
void Remove();
//---- RPC --------------------------------------------------
virtual int OpenConnection(char *server, char *service);
virtual int AnnounceTcpService(char *service);
virtual int AnnounceUnixService(char *server);
virtual int AcceptConnection(int sock);
};
extern System *gSystem;
extern char *gEtDir;
extern int gDebug;
extern bool gInMain;
extern char *gProgname;
extern bool gQuitApp;
extern "C" void _exit(int code);
extern void ETInit(char **argv);
extern void InitSystem();
#endif